﻿using Abp.Domain.Entities.Auditing;
using SingleUserMall.Authorization.Users;
using SingleUserMall.Coupons;
using SingleUserMall.ShoppingCarts;
using SingleUserMall.Workers;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using static SingleUserMall.Items.Item;

namespace SingleUserMall.Orders
{
    public class Order : FullAuditedEntity<long>
    {
        public virtual ICollection<OrderDetail> OrderDetails { get; set; }
        /// <summary>
        /// 用户id
        /// </summary>
        public long UserId { get; set; }
        [ForeignKey("UserId")]
        public virtual User User { get; set; }

        /// <summary>
        ///  购买理财产赠送品朋友的用户Id
        /// </summary>
        public long? FriendUserId { get; set; }
        /// <summary>
        /// 商品Id
        /// </summary>
        public long? ItemId { get; set; }

        /// <summary>
        /// 砍价订单Id
        /// </summary>
        public long? BargainItemId { get; set; }
        /// <summary>
        /// 订单编号
        /// </summary>
        [Required, MaxLength(50)]
        public string OrderNo { get; set; }
        /// <summary>
        ///  状态（-1：取消，0：未提交，1：待付款，2：已付款，3：已成团，4：已发货，5：已收货，6：已评价,7:已失效）
        /// </summary>
        public OrderStatus Status { get; set; }

        /// <summary>
        /// 分红商品状态 0：未开始分红，1：分红中 ，2：分红完成
        /// </summary>
        public DividendStatus? DividendItemStatus { get; set; }
        /// <summary>
        /// 订单类型（0：购物，1：注册）
        /// </summary>
        public OrderType OrderType { get; set; }
        /// <summary>
        /// 支付类型
        /// </summary>
        public PayType PayType { get; set; }
        /// <summary>
        /// 送货方式 （0：3小时快速达，1：1小时极速达（加急费￥10），2：到店自取）
        /// </summary>
        public ShippingType? ShippingType { get; set; }
        /// <summary>
        /// 购物车订单（0：商品购物车订单，1：购买树订单）
        /// </summary>
        public ShoppingCartType? ShoppingCartType { get; set; }
        /// <summary>
        /// 是否团购订单
        /// </summary>
        public bool IsGroup { get; set; }

        /// <summary>
        /// 是否砍价订单
        /// </summary>
        public bool IsBargarin { get; set; }
        /// <summary>
        /// 合计费用
        /// </summary>
        public decimal Amount { get; set; }
        /// <summary>
        /// 实际费用
        /// </summary>
        public decimal ActualAmount { get; set; }
        /// <summary>
        /// 运费
        /// </summary>
        public decimal Freight { get; set; }
        /// <summary>
        /// 包装费
        /// </summary>
        public decimal PackPrice { get; set; }

        /// <summary>
        /// 收货人
        /// </summary>
        [MaxLength(20)]
        public string Receiver { get; set; }
        /// <summary>
        /// 收货人电话
        /// </summary>
        [MaxLength(20)]
        public string ReceiverPhone { get; set; }
        /// <summary>
        /// 收货人地址
        /// </summary>
        [MaxLength(50)]
        public string ReceiverAddress { get; set; }
        /// <summary>
        /// 邮政编码
        /// </summary>
        [MaxLength(10)]
        public string PostalCode { get; set; }
        ///// <summary>
        ///// 配送方式id
        ///// </summary>
        //public int ShippingCategoryId { get; set; }
        //[ForeignKey("ShippingCategoryId")]
        //public virtual ShippingCategory ShippingCategory { get; set; }
        ///<summary>
        /// 支付时间
        /// </summary>
        public DateTime? PayTime { get; set; }

        /// <summary>
        /// 分红结束时间
        /// </summary>
        public DateTime? DividendEndTime { get; set; }
        /// <summary>
        /// 发货时间
        /// </summary>
        public DateTime? ShippingTime { get; set; }
        /// <summary>
        /// 收货时间
        /// </summary>
        public DateTime? ReceiveTime { get; set; }
        /// <summary>
        /// 快递单号
        /// </summary>
        public string ShippingNo { get; set; }
        /// <summary>
        /// 物流消息
        /// </summary>
        public string ShippingLog { get; set; }
        /// <summary>
        /// 上次请求物流消息时间
        /// </summary>
        public DateTime? LastShippingLogTime { get; set; }
        /// <summary>
        /// 是否选中包装费
        /// </summary>
        public bool IsPackPrice { get; set; }

        /// <summary>
        /// 是否是朋友的理财产品
        /// </summary>
        public bool IsFriend { get; set; }
        /// <summary>
        /// 是否是朋友地址
        /// </summary>
        public bool? IsFriendAddress { get; set; }
        /// <summary>
        /// 所有收益归朋友
        /// </summary>
        public bool AllBenefitForFriend { get; set; }
        /// <summary>
        /// 购买最小果树号
        /// </summary>
        public string MinTreeNumber { get; set; }
        /// <summary>
        /// 购买最大果树号
        /// </summary>
        public string MaxTreeNumber { get; set; }

    }
}
